import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'bootstrap'
import '@/assets/css/reset.css'
import 'bootstrap/dist/css/bootstrap.css'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
const app = createApp(App)
app.config.globalProperties.host = 'http://localhost:8000'
app.provide('host', 'http://localhost:8000')
app.use(ElementPlus, {
  locale: zhCn,
})
app.use(store)
app.use(router)
app.mount('#app')
// 防抖函数
const debounce = (fn, delay = 20) => {
  let timer
  return (...args) => {
    if (timer) {
      clearTimeout(timer)
    }
    timer = setTimeout(() => {
      fn(...args)
    }, delay)
  }
}

const _ResizeObserver = window.ResizeObserver
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
  constructor(callback) {
    callback = debounce(callback)
    super(callback)
  }
}
